<!-- 头部 -->
<template>
 
    <div class="tag">
      <vuedraggable class="wrapper">
        <transition-group>
          <router-link
            class="tagTitle"
            :to="item.path"
            :key="index"
            v-for="(item,index) in tags"
            :class="{active:active==index}"
            @click.native="tagClick(index)"
          >
            <el-tag closable :disable-transitions="false" @close="handleClose(index)">
              {{item.title}}
            </el-tag>
          </router-link>
        </transition-group>
      </vuedraggable>
    </div>


</template>

<script>
import { mapGetters, mapMutations } from "vuex";
import vuedraggable from "vuedraggable";

export default {
  name: "",
  components: { vuedraggable },
  data() {
    return {
      active: 0,
    };
  },
  methods: {
    ...mapMutations({
      // 关闭标签
      handleClose: "DEL_TAG_ITEM"
    }),
    tagClick(index) {
      this.active = index;
    }
  },
  computed: {
    ...mapGetters({
      // 所有标签
      tags: "GET_TAGS"
    })
  },
  watch: {},
  created() {},
  mounted() {}
};
</script>
<style lang='scss' scoped>



.tag {
  // position: absolute;
 user-select: none;
  text-align: left;
  margin-bottom: 14px;
  width: 100%;
  height: 30px;
  box-shadow: 0px 3px 5px 1px rgba(0, 0, 0, 0.09);
  // background: #ccc;
  padding: 4px 10px;
  .el-tag {
    height: 100%;
    margin-right: 5px;
  }

  a {
    color: #666;
    // background: transparent;
    text-decoration: none;
  }
}
.active {
  > span {
    background: #42b882;
    color: #fff;
  }
  > span::before {
    content: "";
    background: #fff;
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
    margin-right: 2px;
  }

  color: #fff;
}
</style>